From: Jasper St. Pierre Date: Wed, 2 Jan 2013 14:19:41 +0000 (-0500) Subject: main: Add a better comment about shifting the modal stack X-Git-Tag: archive/raspbian/50.5-1+rpi1~1^2~1013^2^2~5127 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=73388f30fd638782c99bafa1f4829ff14978112b;p=gnome-shell.git main: Add a better comment about shifting the modal stack It took me a few minutes to realize why, so let's just add this in for future reference. https://bugzilla.gnome.org/show_bug.cgi?id=690965 --- diff --git a/js/ui/main.js b/js/ui/main.js index 8c9136a5a..b907eb9c2 100644 --- a/js/ui/main.js +++ b/js/ui/main.js @@ -606,6 +606,21 @@ function popModal(actor, timestamp) { keybindingMode = record.keybindingMode; global.stage.set_key_focus(record.prevFocus); } else { + // If we have: + // global.stage.set_focus(a); + // Main.pushModal(b); + // Main.pushModal(c); + // Main.pushModal(d); + // + // then we have the stack: + // [{ prevFocus: a, actor: b }, + // { prevFocus: b, actor: c }, + // { prevFocus: c, actor: d }] + // + // When actor c is destroyed/popped, if we only simply remove the + // record, then the focus stack will be [a, c], rather than the correct + // [a, b]. Shift the focus stack up before removing the record to ensure + // that we get the correct result. let t = modalActorFocusStack[modalActorFocusStack.length - 1]; if (t.prevFocus) t.prevFocus.disconnect(t.prevFocusDestroyId);